<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            采购管理
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="../css/x-admin.css" media="all">
        <link rel="stylesheet" href="../css/pag.css" media="all">
        <link rel="stylesheet" href="../css/pag.css" media="all">
        <link rel="stylesheet" href="../css/sbgl.css" media="all" type="text/css">
       
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
             <h2>
					 采购管理 <img src="../images/user1.png" alt="" height="20px" width="20px" /><small>
						- 您可以通过搜索或者其他的筛选项对采购的信息进行修改、删除等管理操作。^_^</small>
				</h2>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
        <form class="layui-form x-center" action="${pageContext.request.contextPath}/cggl/getAll" style="width:500px">
            <input type="hidden" name="currentPageNo" value="1"/>
                <div class="layui-form-pane">
                  <div class="layui-form-item">
                    <div class="layui-input-inline" style="width:400px">
                      <input type="text" name="mohuName" value="${mohuName}" placeholder="搜索内容" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:80px">
                        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                    </div>
                  </div>
                </div> 
            </form>
            <div class="tools">
    <ul class="toolbar">
      <li id="delBatch"><span><img src="../images/t03.png" /></span>批量删除</li>
      <li onclick="sbgl_add('添加用户','/cggl/goAdd','600','500')"><span><img src="../images/t01.png" /></span>添加</li>
    </ul>
    <span class="x-right" style="line-height:25px">共有数据:${totalCount}条</span></xblock>
    <span class="x-right" style="line-height:25px" align="left">第${currentPageNo}页/共${totalPageCount}页</span>
  </div>
            <table class="tablelist">
                <thead>
                    <tr>
                        <th width="4%">
                            <input onclick="selectAll()" type="checkbox"   name="controlAll" style="controlAll" id="controlAll">
                        </th>
                        <th width="5%">申请表</th>
                        <th width="7%">购买编号</th>
                        <th width="7%">购买型号</th>
                        <th width="7%">产品类型</th>
                        <th width="11%">产品用途</th>
                        <th width="6%">设备单价</th>
                        <th width="6%">数量</th>
                        <th width="6%">科室</th>
                        <th width="6%">申请人</th>
                        <th width="6%">申请日期</th>
                        <th width="6%">审批人</th>
                        <th width="6%">审批日期</th>
                        <th width="6%">设备总金额</th>
                        <th width="6%">审批状态</th>
                        <th width="7%">操作</th>
                    </tr>
                <c:forEach var="Buy" items="${buyList}" varStatus="row">
                    <tr>
                        <th width="4%">
                            <input onclick="selectAll()" type="checkbox" value="${Buy.bId}"  name="controlAll" style="controlAll" id="controlAll">
                        </th>
                        <th>${Buy.bId}</th>
                        <th>${Buy.bCode}</th>
                        <th>${Buy.bType}</th>
                        <th>
                                ${Buy.cpType}
                        </th>
                        <th>${Buy.cpUse}</th>
                        <th>${Buy.price}</th>
                        <th>${Buy.buyNumber}</th>
                        <th>
                                ${Buy.kName}
                        </th>
                        <th>${Buy.docName}</th>
                        <th>
                            <fmt:formatDate value="${Buy.sqTime}" pattern="yyyy-MM-dd"/>
                        </th>
                        <th>${Buy.spPerson}</th>
                        <th>
                            <fmt:formatDate value="${Buy.spTime}" pattern="yyyy-MM-dd"/>
                        </th>
                        <th>${Buy.totalPrice}</th>
                        <th>
                            <c:if test="${Buy.spZt eq 0}">未通过</c:if>
                            <c:if test="${Buy.spZt eq 1}">通过</c:if>
                        </th>

                        <th class="td-manage">
                            <a style="text-decoration:none" onclick="chakan(${Buy.bId})" href="javascript:;" title="查看">
                                <i class="layui-icon"></i>
                            </a>
                                <%--<a style="text-decoration:none" href="${pageContext.request.contextPath}/sbgl/seesbkc?sId=${SheBeiKuCun.sId}" title="查看">--%>
                                <%--<i class="layui-icon"></i>--%>
                                <%--</a>--%>
                                <%--<a title="修改" href="javascript:;" onclick="home_edit('修改','/jsp/home_edit.html','4','','510')"--%>
                            <a title="修改" href="javascript:;" onclick="sbgl_edit('修改','/cggl/goUpdate?bId=${Buy.bId}','4','','510')"
                               class="ml-5" style="text-decoration:none">
                                <i class="layui-icon">&#xe642;</i>
                            </a>
                            <a title="删除" href="javascript:;" onclick="banner_del(${Buy.bId})"
                               style="text-decoration:none">
                                <i class="layui-icon" >&#xe640;</i>
                            </a>
                        </th>
                    </tr>
                </c:forEach>
                </thead>
                <tbody id="x-img">

                </tbody>
            </table>
            <div class="page" v-show="show">
                <div class="pagelist">
                    <input type="hidden" id="totalPageCount" value="${totalPageCount}">
                    <c:if test="${currentPageNo>1}">
                        <span class="jump"><a href="javascript:page_nav(document.forms[0],1);">首页</a></span>
                        <span class="jump"><a href="javascript:page_nav(document.forms[0],${currentPageNo - 1});">上一页</a></span>
                    </c:if>
                    <c:if test="${currentPageNo<totalPageCount}">
                        <span class="jump"><a href="javascript:page_nav(document.forms[0],${currentPageNo + 1});">下一页</a></span>
                        <span class="jump"><a href="javascript:page_nav(document.forms[0],${totalPageCount});">尾页</a></span>
                    </c:if>
                    <span class="jumppoint">跳转到：</span>
                    <span class="jumpinp"><input type="text" name="inputPage" id="inputPage" value=""></span>
                    <button type="button" class="jump gobtn" onclick="jump_to(document.forms[0],document.getElementById('inputPage').value)">GO</button>
                </div>
                <div>
                    <div id="page_container">
                    </div>
                </div>
            </div>
</div>
<br />
<br />
<br />
        <script src="../lib/layui/layui.js" charset="utf-8"></script>
        <script src="../js/x-layui.js" charset="utf-8"></script>
        <script src="../js/sbgl/rollpage.js"></script>
<script src="../js/jquery2.js" charset="utf-8"></script>
<script src="../js/js.js" charset="utf-8"></script>
        <script>
            layui.use(['laydate','element','laypage','layer'], function(){
                $ = layui.jquery;
              lement = layui.element;//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层
            });


            /*添加*/
            function sbgl_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }

            // 编辑
            function sbgl_edit (title,url,id,w,h) {
                x_admin_show(title,url,w,h);
            }
	$('.tablelist tbody tr:odd').addClass('odd');

            //单个删除设备
            function banner_del(bId) {
                var tips =confirm("是否确认删除");//弹出确认框，点击是则tips为true  否则为false;
                if(tips) {//如果点击确认  进行if里的操作(确认删除)
                    $.ajax({
                        type: "get",
                        url: "/cggl/del/" + bId,
                        dataType: "json",
                        success: function (data) {
                            var flag = data.retMsg;
                            if (flag) {
                                // layer.msg("删除成功");
                                layer.open({
                                    title: '信息',
                                    content: '删除成功',
                                    end: function () {
                                        location.reload();
                                    }
                                });
                            } else {
                                layer.msg("删除失败");
                            }
                        },
                        error: function () {
                            layer.msg("删除异常");
                        }
                    })
                }else{
                    return false;//如果取消  则返回false
                }
            }
            //批量删除
            $("#delBatch").bind("click",function () {
                var tips =confirm("是否确认删除");//弹出确认框，点击是则tips为true  否则为false;
                if(tips){//如果点击确认  进行if里的操作(确认删除)
                    var x = $("input[name='controlAll']");//获取所有的checkbox
                    var list = new Array();//构造传入后台的数据。
                    for(var i = 0;i<x.length;i++){//遍历所有checkbox
                        if(x[i].checked){//检查每个box是否选中
                            list.push(parseInt(x[i].value));//选中的将box的value push进入list
                        }
                    }
                    if(list.length>0){//如果list的长度大于0  不为空  则进行ajax校验
                        $.ajax({
                            url:"${pageContext.request.contextPath}/cggl/delBatch",//后台url
                            type:"post",//后台进行接收的方法
                            dataType:"json",//前台接收的数据格式
                            data:{"delList":JSON.stringify(list)},//传入的数据，json格式   {"delList":[1,2,3]}  key 为 string   value 为 数组
                            success:function (data) {
                                if(data.msg=="success"){//如果后台返回的json的msg为success
                                    layer.open({//弹出提示框，
                                        title:"提示",//标题
                                        content:"删除成功",//内容
                                        end:function () {//弹框消失后的回调函数
                                            location.reload();//刷新页面
                                        }
                                    });
                                }else if(data.msg == "failed"){//后台返回的msg为failed   删除失败的操作
                                    layer.open({
                                        title:"提示",
                                        content:"删除失败",
                                        end:function () {
                                            location.reload();
                                        }
                                    });
                                }else{
                                    console.log(data);//不可能事件
                                }
                            },error:function (e) {//ajax的失败回调
                                console.log(e)//打印e
                            }
                        })
                    }else{
                        layer.msg("请选择序号！",{icon:2})
                        return false;//如果未选择box  则返回false
                    }
                }else{
                    return false;//如果取消  则返回false
                }
            })

            //设备详情
            function chakan(bId) {
                layer.open({
                    type: 2,
                    area: ['850px', '850px'],
                    fix: false, //不固定
                    maxmin: true,
                    shadeClose: true,
                    shade: 0.4,
                    title: '采购详情信息',
                    content: '/cggl/see_gm?bId=' + bId,
                    end:function () {
                        //window.location.reload();//刷新本页面
                    }
                });
            }
            </script>
    </body>
</html>